﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ResourcesManagement;
using System.Globalization;
using System.Runtime.Serialization;

namespace YasharEl.Infrastructure.TaskEngine
{
    [Serializable]
    public class AnotherTaskActionAlreadyExecutedException : TranslatedDomainModelException
    {
        private const string AnotherTaskActionAlreadyExecuted = "AnotherTaskActionAlreadyExecuted";

        private readonly long _taskId;

        public long TaskId
        {
            get { return _taskId; }
        }

        public AnotherTaskActionAlreadyExecutedException(IResourceManager resourceManager, long taskId)
            : base
             (
                resourceManager,
                string.Format(
                    resourceManager.GetString(AnotherTaskActionAlreadyExecuted, CultureInfo.GetCultureInfo("en")),
                    taskId
                )
             )
        {
            _taskId = taskId;
        }

        protected AnotherTaskActionAlreadyExecutedException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        protected override string ExceptionMessageResourceKey
        {
            get { return AnotherTaskActionAlreadyExecuted; }
        }

        public override string TranslatedMessage
        {
            get
            {
                return string.Format(resourceManager.GetString(ExceptionMessageResourceKey), TaskId);
            }
        }
    }
}
